<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,maximum-scale=1.0" />
    <title><#if entity.id??>编辑<#else>新增</#if>首页3个商品表</title>
    <#include "/view/admin/head.html"/>
    <script type="text/javascript" src="${base}/jstool/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript" src="${base}/jstool/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/jstool/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />


    <script type="text/javascript" src="${base}/jstool/bootstrap-validator-0.5.3/js/bootstrapValidator.min.js"></script>
    <script type="text/javascript" src="${base}/jstool/bootstrap-validator-0.5.3/lang/zh_CN.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/jstool/bootstrap-validator-0.5.3/css/bootstrapValidator.min.css" />

    <script type="text/javascript" src="${base}/jstool/bootstrap-select/js/bootstrap-select.min.js"></script>
    <script type="text/javascript" src="${base}/jstool/bootstrap-select/lang/defaults-zh_CN.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/jstool/bootstrap-select/css/bootstrap-select.min.css" />

    <script type="text/javascript" src="${base}/jstool/bootstrap-fileinput/js/fileinput.js"></script>
    <script type="text/javascript" src="${base}/jstool/bootstrap-fileinput/js/locals/zh.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/jstool/bootstrap-fileinput/css/fileinput.min.css" />


    <style type="text/css">
        .list-path {
            height: 50px;
            line-height: 50px;
            background-color: #9acfea;
        }

        .table-class {
            width: 90%;
            text-align: center;
            border: 1px solid #afd9ee;
            margin: 0 auto;
            margin-top: 50px;
        }

        table th {
            width: 20%;
            background-color: #d9edf7;
            text-align: right;
        }

        table td {
            width: 20%;
            text-align: left;
        }


    </style>
    <script type="text/javascript">

        $(function(){
            //初始化

            $(function() {
                $('input[type="file"]').fileinput({

                    language: 'zh', //设置语言
//                allowedFileExtensions: ['jpg', 'png', 'gif'],//接收的文件后缀
                    showUpload: false, //是否显示上传按钮
                    showCaption: false,//是否显示标题
//                browseClass: "btn btn-primary", //按钮样式
//                previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
                    overwriteInitial: false,
                    showPreview:true
//                overwriteInitial:false
                });
            });




            $('#czjcommodity3Form').bootstrapValidator({
                message: 'This value is not valid',
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {



                    
                orderby:{
                    message: '输入顺序出错',
                    validators:{
                        notEmpty: {
                            message: '顺序不能为空'
                        },
                        stringLength:{
                            max: 1,
                            message: '顺序不能超过 1个字符'
                        },
                        regexp: {
                            regexp: /^[0-9]+$/,
                                    message:'顺序只能是数字'
                        }
                    }
                }


                }
            });


        });

    </script>
</head>
<body>

<#include "/view/admin/listnav.html"/>


<div class="table-class">
    <#include "/view/admin/opermsg.html"/>
    <form id="czjcommodity3Form" action="${base}/czjcommodity3/save.do"
          method="post" enctype="multipart/form-data"
     >
    <table class="table table-bordered">

                        <input type="hidden" style="display: none" name="id" value="${entity.id!}"/>


                <tr>
                <th>顺序</th>
                <td>
                    <div class="form-group">
                        <input type="text" class="form-control" id="orderby" name="orderby" placeholder="请输入顺序" value="${entity.orderby!}">
                    </div>
                </td>
                </tr>
                <tr>
                
                <th>商家</th>
                <td>
                    <div class="form-group">

                            <select name="business" id="businessList" class="form-control input-small" onchange="javascript:businessChange()">
                                <option>--请选择商家--</option>
                                <#list listBusiness as business>
                                    <option value="${business.value!}" <#if business.value??&&entity.businessId??&&entity.businessId==business.value>selected="selected"</#if>>${business.name!}</option>
                                </#list>
                            </select>


                    </div>
                </tr>
        <tr>
            <th>商品</th>
            <td>
            <div class="form-group">

                <select name="commodityId" id="commodityList" class="form-control input-small">
                    <option>--请选择商品--</option>
                    <#if listCommodityId??><#list listCommodityId as lv>
                        <option value="${lv.value!}"
                        <#if lv.value??&&entity.commodityId??&&entity.commodityId == lv.value >
                            selected="selected"
                        </#if>
                        >${lv.name!}</option>
                    </#list>
                    </#if>
                </select>

            </div>
                  <#--  <div class="form-group">
                        <select id="commodityId" name="commodityId"
                                class="form-control selectpicker"   data-live-search="true"
                        >
                            <option value="">请选择商品</option>
                                    <#list listCommodityId as lv>
                                        <option value="${lv.value!}"
                                        <#if lv.value??&&entity.commodityId??&&entity.commodityId == lv.value >
                                            selected="selected"
                                        </#if>
                                            >${lv.name!}</option>
                                    </#list>

                        </select>
                    </div>-->
                </td>
                </tr>

       <tr>
           <th>显示图片（不上传，则使用原来商品的图片）（尺寸：240X240）</th>
           <td>
            <#if entity.picPath??>
                <img src="${base}${entity.picPath!}" height="100px">
            </#if>

            <input type="file" class="form-control" id="picPath" name="filePicPath" >
           </td>
        </tr>
        <tr>
            <td colspan="2" width="100%" style="text-align: center;">
                <input type="submit" class="btn btn-success " value="保存"/>
                <span style="width: 20px;">&nbsp;</span>
                <a class="btn btn-danger " href="javascript:window.history.go(-1)">
                   </span>返回</a>
            </td>
        </tr>

    </table>
</form>




</div>

<script type="text/javascript">
    function businessChange() {

        var type = $("#businessList").val();

        var html = "";
        var CommitUrl = "getBusinessIds.do?id=" + type;

        $.ajax({
            type : "POST",
            contentType : "application/json",
            url : CommitUrl,
            dataType : 'json',
            success : function(result) {
                var Curedata = $.extend(true, [], result);
                    for ( var i = 0; i < Curedata.length; i++) {

                        html += "<option value='"+Curedata[i].id+"'>"+ Curedata[i].commodityName
                            + "</option>";
                    }
                    $("#commodityList").empty();
                    $(html).appendTo("#commodityList");

                }

        });
    }
</script>


</body>
</html>
